import mongoose from 'mongoose'
import { createUid } from 'creality-utils'

// 供应商表
const schema = new mongoose.Schema({
    // 公司名称
    company: {
      type: String,
      required: [true, "请添加公司名称"],
    },
    // 姓名
    name: {
      type: String,
      required: [true, "请添加名字"],
    },
    // 联系电话
    phone: {
      type: Number,
      required: true,
    },
    // 其他联系电话
    otherPhone: {
      type: Number,
      required: false,
    },
    // 备注
    remarks: {
      type: String,
      required: false,
    },
    id: {
      type: String,
      default: createUid(),
    },
    createTime: {
      type: Number,
      default: new Date().getTime(),
    }
}, {
    // 日期
    timestamps: {
      createdAt: '_createTime',
      updatedAt: '_updateTime'
    }
})

export default mongoose.model('suppliers', schema)